package cn.bb.bbstudy.service.impl;

import cn.bb.bbstudy.dao.CommentDAO;
import cn.bb.bbstudy.pojo.Comment;
import cn.bb.bbstudy.service.CommentService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class CommentServiceImpl implements CommentService{

    @Resource
    private CommentDAO commentDAO;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return commentDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Comment record) {
        return commentDAO.insert(record);
    }

    @Override
    public int insertSelective(Comment record) {
        return commentDAO.insertSelective(record);
    }

    @Override
    public Comment selectByPrimaryKey(Integer id) {
        return commentDAO.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Comment record) {
        return commentDAO.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Comment record) {
        return commentDAO.updateByPrimaryKey(record);
    }

    public List<Comment> selectAllByTopic(String topId) {
        return commentDAO.selectAllByTopic(topId);
    }

    public int count(String uid) {
        return commentDAO.count(uid);
    }

    public Page<Comment> selectAllByUid(String uid) {
        return commentDAO.selectAllByUid(uid);
    }

    public void deleteCommentByCid(String cid) {
         commentDAO.deleteCommentByCid(cid);
    }
}
